import Request from '../static/js/request.js';
let request = new Request().http;

import UploadFile from '../static/js/upload.js';
let uploadFile = new UploadFile().http;

export default{
	logined:function(upJson){//用户登录
		return request({url:"/api/auth/login",data:upJson,bMsg:"登录中",methods:"POST",type:1})
	},
	getWxUserinfo:function(upJson){//微信用户授权
		return request({url:"/api/auth/weapi",data:upJson,bMsg:"登录中",methods:"POST",type:1})
	},
	getUserInfo:function(upJson){//获取用户信息
		return request({url:"/api/info/info_user",data:upJson,methods:"POST"})
	},
	editUserInfo:function(upJson){//编辑用户信息
		return request({url:"/api/info/update_user",data:upJson,back:true,type:3,eMsg:"修改成功",methods:"POST"})
	},
	addClient:function(upJson,type){//增改商户
		if(type == 0){
			return request({url:"/api/customer/create",data:upJson,back:true,type:3,eMsg:"保存成功", methods:"POST"})
		}else{
			return request({url:"/api/customer/update",data:upJson,back:true,type:3,eMsg:"修改成功",methods:"POST"})
		}
	},
	getClientTypeList:function(upJson){//获取商户类型列表
		return request({url:"/api/common/customer_type",data:upJson,methods:"POST"})
	},
	getClientList:function(upJson){//获取商户列表
		return request({url:"/api/customer/lists",data:upJson,methods:"POST"})
	},
	getClientLabel:function(upJson){//获取商户列表
		return request({url:"/api/customer/customer_tags",data:upJson,methods:"GET"})
	},
	getClientDetails:function(upJson,type){//获取商户数据
		if(type == 0){//商户详情
			return request({url:"/api/customer/details",data:upJson, methods:"POST"})
		}else if(type == 1){//商户设备类别
			return request({url:"/api/customer/device_list",data:upJson, methods:"GET"})
		}else if(type == 2){//商户派工列表
			return request({url:"/api/work/lists",data:upJson, methods:"GET"})
		}else if(type == 3){//商户拜访列表
			return request({url:"/api/customer/visit_list",data:upJson, methods:"GET"})
		}else if(type == 4){//商户联系人列表
			return request({url:"/api/customer/contact_list",data:upJson, methods:"GET"})
		}else if(type == 5){ // 商户订单列表
			return request({url:"/api/order/order_lists",data:upJson,methods:"POST"})
		}
	},
	getVisitSign:function(upJson){//拜访签到
		return request({url:"/api/customer/visit_sign", data:upJson, methods:"POST"})
	},
	getClientEquipmentDetail:function(upJson){//客户设备详情
		return request({url:"/api/customer/device_detail",data:upJson, methods:"GET"})
	},
	getDeviceRecord:function(upJson){//维修保养记录
		return request({url:"/api/customer/device_record",data:upJson, methods:"GET"})
	},
	addClientEquipment:function(upJson){//客户新增设备
		return request({url:"/api/customer/device_create",data:upJson,back:true,type:3,methods:"POST"})
	},
	editClientEquipment:function(upJson){//客户编辑设备
		return request({url:"/api/customer/device_update",data:upJson,back:true,type:3,methods:"POST"})
	},
	addClientPhone:function(upJson){//客户新增联系人
		return request({url:"/api/customer/update_contact",data:upJson,back:true,type:3,methods:"POST"})
	},
	getClientVisitType:function(upJson){//获取拜访类型
		return request({url:"/api/customer/visit_type",data:upJson,methods:"GET"})
	},
	addClientVisit:function(upJson,type){//客户新增拜访
		if(type == 0){
			return request({url:"/api/customer/visit_detail",data:upJson,methods:"GET"})
		}else if(type == 1){
			return request({url:"/api/merchant/modifyVisit",data:upJson,back:true,type:3,eMsg:"修改成功"})
		}else if(type == 2){
			return request({url:"/api/customer/visit_answer",data:upJson,back:true,type:3,eMsg:"留言成功"})
		}else if(type == 4){
			return request({url:"/api/customer/visit_del",data:upJson,methods:"POST"})
		}else if(type == 5){ 
			return request({url:"/api/customer/visit_customer",data:upJson,back:true,type:3,methods:"POST"})
		}
	},
	getRepeatCustomer:function(upJson){ //查重
		return request({url:"/api/customer/repeat_customer", data:upJson, methods:"GET"})
	},
	
	getWorkList:function(upJson,type){//获取工单列表
		return request({url:"/api/work/lists",data:upJson, methods:"GET"})
	},
	getWorkDetail:function(upJson){ // 获取工单详情
		return request({url:"/api/work/details", data:upJson, methods:"GET"})
	},
	getWorkType:function(upJson){ // 获取工单类型
		return request({url:"/api/work/work_type", data:upJson, methods:"GET"})
	},
	getWorkSign:function(upJson){ // 工单签到
		return request({url: "/api/work/sign", data:upJson , methods:"POST"})
	},
	getWorkCreact:function(upJson){ // 派单
		return request({url: '/api/work/work_create', data: upJson, type:3, eMsg:保存成功', methods:"POST"})
	},
	getWorkComplete:function(upJson){  // 完成工单
		return request({url: "/api/work/complete", data:upJson, type:3, eMsg: '完成工单', methods:"POST"})
	},
	getCreatDesc:function(upJson){ // 添加描述
	  return request({url:"/api/work/create_desc",data:upJson,type:3,eMsg:'添加描述成功',methods:"POST"})
	},
	getUpdateDesc:function(upJson){ // 添加描述
	  return request({url:"/api/work/update_desc",data:upJson,type:3,eMsg:'修改描述成功',methods:"POST"})
	},
	
	
	
	getOrderStatus:function(upJson){ // 订单状态
		return request({url:"/api/order/order_status",data:upJson, methods:"GET"})
	},	
	getOrderAudit:function(upJson){//审核成交
		return request({url:"/api/order/order_audit", data:upJson, methods:"GET"})
	},
	getStatistics:function(upJson,type){//获取订单统计
		return request({url:"/api/order/order_statistics",data:upJson,methods:"POST"})
	},
	getOrderList:function(upJson,type){//获取订单列表
		return request({url:"/api/order/order_lists",data:upJson,methods:"POST"})
	},
	getOrderClass:function(upJson,type){//获取订单类别
		return request({url:"/api/order/order_class",data:upJson,methods:"GET"})
	},
	getOrderPayMethods:function(upJson,type){//获取订单收款方式
		return request({url:"/api/order/payment_method",data:upJson,methods:"GET"})
	},
	getOrderInvoiceType:function(upJson,type){//获取发票类型
		return request({url:"/api/order/invoice_type",data:upJson,methods:"GET"})
	},
	addOrder:function(upJson){//新增订单
		return request({url:"/api/order/create_order",data:upJson,methods:"POST",back:true,type:3,eMsg:"新增成功"})
	},
	getOrderDetail:function(upJson){ // 获取订单详情
		return request({url:"/api/order/order_detail",data:upJson, methods:"GET"})	
	},
	getOrderSchedule:function(upJson){// 订单进度
		return request({url:"/api/order/order_schedule", data:upJson, methods:"GET"})
	},
	editSchedule:function(upJson){//修改进度
		return request({url:"/api/order/edit_schedule", data:upJson, eMsg:"修改成功", methods:"GET"})
	},
	
	
	
	getProductLibrary:function(upJson,type){//获取产品仓库
		return request({url:"/api/common/warehouse",data:upJson,methods:"POST"})
	},
	getProductType:function(upJson,type){//获取产品类型
		return request({url:"/api/common/product_type",data:upJson,methods:"POST"})
	},
	getProductList:function(upJson,type){//获取产品列表
		return request({url:"/api/product/lists",data:upJson,methods:"POST"})
	},
	getProductInfo:function(upJson,type){//获取产品详情
		return request({url:"/api/product/details",data:upJson,methods:"POST"})
	},
	getProductIntoList:function(upJson,type){//获取产品出入库状态列表 0入库状态 1出库状态
		return request({url:"/api/product/order_type",data:upJson,methods:"GET"})
	},
	getProductMoveList:function(upJson,type){//获取产品调拨状态列表
		return request({url:"/api/product/get_change",data:upJson,methods:"POST"})
	},
	getProductStock:function(upJson,type){//获取产品库存信息
		return request({url:"/api/product/stock",data:upJson,methods:"GET"})
	},
	getProductOut:function(upJson,type){//获取产品销售应发货
		return request({url:"/api/product/sale_shipped",data:upJson,methods:"GET"})
	},
	getProductClass:function(upJson,type){//获取产品类别
		return request({url:"/api/order/order_class",data:upJson,methods:"GET"})
	},
	moveProduct:function(upJson,type){//产品调拨
		return request({url:"/api/product/change_warehouse",data:upJson,methods:"POST",back:true,type:3})
	},
	changeProductPrice:function(upJson,type){//修改产品价格
		return request({url:"/api/product/update_price",data:upJson,methods:"POST",back:true,type:3})
	},
	deleteProduct:function(upJson,type){//删除产品
		return request({url:"/api/product/remove",data:upJson,methods:"POST"})
	},
	addPutLibrary:function(upJson,type){//产品出库
		return request({url:"/api/product/product_put",data:upJson,methods:"POST",back:true,type:3})
	},
	addIntoLibrary:function(upJson,type){//产品入库
		return request({url:"/api/product/product_into",data:upJson,methods:"POST",back:true,type:3})
	},
	getSupplierList:function(upJson,type){//获取供应商列表
		return request({url:"/api/product/supplier_list",data:upJson,methods:"GET"})
	},
	getLibraryList:function(upJson,type){//获取资料库列表
		return request({url:"/api/common/material",data:upJson,methods:"POST"})
	},
	getLibraryInfo:function(upJson,type){//获取资料库详情
		return request({url:"/api/common/material_details",data:upJson,methods:"POST"})
	},
	getAccessoriesLibrary:function(upJson,type){//获取配件仓库列表
		return request({url:"/api/product/parts_list_all",data:upJson,methods:"GET"})
	},
	getAccessoriesType:function(upJson,type){//获取配件类型
		return request({url:"/api/product/parts_type",data:upJson,methods:"POST"})
	},
	getAccessoriesList:function(upJson,type){//获取配件列表
		return request({url:"/api/product/parts_list",data:upJson,methods:"POST"})
	},
	getMyAccessoriesList:function(upJson,type){//获取我的配件列表
		return request({url:"/api/product/my_parts",data:upJson,methods:"GET"})
	},
	getMyAccessoriesInfo:function(upJson,type){//获取我的配件详情
		return request({url:"/api/product/my_parts_details",data:upJson,methods:"GET"})
	},
	drawAccessories:function(upJson,type){//获取我的配件详情
		return request({url:"/api/product/receive_parts",data:upJson,methods:"POST",back:true,type:3,bMsg:"领取中"})
	},
	
	getReturnList:function(upJson,type){//获取退换货列表
		return request({url:"/api/order/relate_list",data:upJson,methods:"GET"})
	},
	
	
	getBranchList:function(upJson){//获取部门列表
		return request({url:"/api/common/branch_list", data:upJson,methods:"POST"})
	},
	getUserList:function(upJson){//获取部门人员列表
		return request({url:"/api/user/lists",data:upJson,methods:"GET"})
	},
	uploadFile:function(upJson){//文件上传
		return uploadFile({url:"/api/common/upload",data:upJson})
	},
	getTimeString:function(time){//时间转时间戳
		if(time.length == 10){
			time += " 00:00:00";
		}
		time = time.split("-");
		time.length == 2 ? time = time[0] : time = time[0] + '/' + time[1] + '/' + time[2];
		return Date.parse(new Date(time)) / 1000
	},
	getNowTime:function(){//获取当前时间
		let time = new Date();
		let y = time.getFullYear();
		let m = time.getMonth() < 9 ? "0" + (time.getMonth() + 1) : time.getMonth() + 1
		let d = time.getDate() < 10 ? "0" + time.getDate() : time.getDate()
		return y + "-" + m + "-" + d
	},
	prompt:function(title){
		uni.showToast({title,icon:"none"})
	}
}